package com.ocom.common.utils;

import com.alibaba.fastjson.JSONObject;

import java.util.Map;

public class JsonResponse extends JSONObject {
	private static final long serialVersionUID = 1L;
	
	public JsonResponse() {
		put("result", "0000");
	}
	
	public static JsonResponse noVerify() {
		return error("","");
	}

	public static JsonResponse error() {
		return error("2300", "未知异常，请联系管理员");
	}
	
	public static JsonResponse error(String msg) {
		return error("", msg);
	}
	
	public static JsonResponse error(String result, String msg) {
		JsonResponse r = new JsonResponse();
		r.put("result", result);
		r.put("msg", msg);
		return r;
	}

	public static JsonResponse error(String result, String msg, Object data) {
		JsonResponse r = new JsonResponse();
		r.put("result", result);
		r.put("msg", msg);
		r.put("data", data);
		return r;
	}


	public static JsonResponse success(int code, String msg) {
		JsonResponse r = new JsonResponse();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}

	public static JsonResponse success(String msg, Object data) {
		JsonResponse r = new JsonResponse();
		r.put("msg", msg);
		r.put("data", data);
		return r;
	}

	public static JsonResponse success(String result, String msg, String data) {
		JsonResponse r = new JsonResponse();
		r.put("result", result);
		r.put("msg", msg);
		r.put("data", data);
		return r;
	}

	public static JsonResponse success(String result, String msg, Object data) {
		JsonResponse r = new JsonResponse();
		r.put("result", result);
		r.put("msg", msg);
		r.put("data", data);
		return r;
	}
	
	public static JsonResponse success(Map<String, Object> map) {
		JsonResponse r = new JsonResponse();
		r.put("msg", "success");
		r.put("data", map);
		return r;
	}
	
	public static JsonResponse success(String msg, Map<String, Object> map) {
		JsonResponse r = new JsonResponse();
		r.put("msg", msg);
		r.put("data", map);
		return r;
	}
	
	public static JsonResponse success() {
		JsonResponse r = new JsonResponse();
		r.put("msg", "success");
		return r;
	}
	
	public static JsonResponse success(Object data) {
		JsonResponse r = new JsonResponse();
		r.put("msg", "success");
		r.put("data", data);
		return r;
	}

}
